<?php
class Member extends AppModel {
	var $name = 'Member';
	
	var $virtualFields = array(
		'name_and_number' => 'CONCAT(Member.name, " ", Member.camarilla_number)'
	);
	
	var $validate = array(
		'name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'camarilla_number' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
			'camarilla_number' => array(
				'rule' => '/^[A-Z]{2}[0-9]{6,12}(T|)$/',
				'message' => 'Camarilla number not valid, please use contry code in caps and correct number of digets'
			),
			'isUnique' => array(
				'rule' => 'isUnique',
				'message' => 'Camarilla number already exists'
			)
		),
		'location_id' => array(
			'notempty' => array(
				'rule' => array('notempty')
			)
		)
	);
    
    public $hasOne = array(
        'User' => array(
            'className' => 'User',
            'foreignKey' => 'member_id',
            'dependent' => true
        )
    );

	var $hasMany = array(
		'Request' => array(
			'className' => 'Request',
			'foreignKey' => 'member_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);
	
	public $belongsTo = array(
		'Location' => array(
			'className' => 'Location',
			'foreignKey' => 'location_id',
			'dependent' => false
		)
	);

}
?>